<?php

class Announcement_Controller_Admincp_Add extends Nuo_Controller_Admincp
{

	function execute($request)
	{
		Nuo::setVar('breadcrum', array(
			'title' => 'Browse Announcement',
			'toolbar' => 'admincp/announcement'
		));

		$form = Nuo::getObject('announcement/admincp/add', 'form');

		$table = Nuo::getTable('announcement/post');

		if ($request -> isPost() && $form -> isValid($_POST))
		{
			
			$data = $form->getData();
			
			$item = $table -> fetchNew();

			$item -> fromArray($data);

			$item -> created_at = $item -> updated_at = time();
			
			$item -> save();

			$uri = Nuo::getUrl('admincp/announcement');


			Nuo::redirect($uri);
		}

		return  Nuo::getView()->render('core/view/controller/admincp/edit', array('form' => $form));
	}

}
